package com.app.service.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.app.activity.R;
import com.app.data.InnItem;
import com.app.data.LineItem;
import com.app.service.adapter.HotelAdapter.HotelHandle;

public class LineAdapter extends DataAdapter {

	ArrayList<LineItem> lines;
	public LineAdapter(Activity parentActivity) {
		super(parentActivity);
		// TODO Auto-generated constructor stub
	}

	private ArrayList<LineItem> hotels;
	public LineAdapter(Activity parentActivity ,ArrayList<LineItem> lines)
	{
		this(parentActivity);
		this.lines = lines;
	}
	@Override
	public int getCount() {
		return lines.size();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LineHandle handle;
		if (convertView == null) {
			handle=new LineHandle();
			convertView = LayoutInflater.from(parentActivity).inflate(R.layout.line_list_item, null);
			handle.iconImg = (ImageView)convertView.findViewById(R.id.imgLineIcon);
			handle.contentView = (TextView)convertView.findViewById(R.id.tvLineName);
			handle.desView = (TextView)convertView.findViewById(R.id.tvLineTransport);
			handle.priceView = (TextView)convertView.findViewById(R.id.tvLinePrice);
			convertView.setTag(handle);
		}else {
			handle = (LineHandle)convertView.getTag();
		}
		LineItem item = lines.get(position);
		handle.iconImg.setImageBitmap(item.getIconbitmap());
		handle.contentView.setText(item.getLineName());
		handle.desView.setText(item.getLineTransport());
		handle.priceView.setText(item.getLinePrice());
		
		return convertView;
	}

	
	class LineHandle
	{
		ImageView iconImg;
		TextView contentView;
		TextView desView;
		TextView priceView;
	}
}
